﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Data;

namespace MovingChame.WindowsStoreApp.Converters
{
    public class BoolToVisibilityConverter : IValueConverter
    {

        public object Convert(object value, Type targetType, object parameter, string language)
        {
            bool isVisible = (bool)value;
            if (parameter != null && parameter as string == "Reverse")
                isVisible = !isVisible;
            return isVisible ? Visibility.Visible : Visibility.Collapsed;
        }

        public object ConvertBack(object value, Type targetType, object parameter, string language)
        {
            Visibility currVisibility = (Visibility)value;
            bool result = currVisibility == Visibility.Visible;
            if (parameter != null && parameter as string == "Reverse")
                result = !result;
            return result;
        }
    }
}
